package 蓝桥.十五届;

import java.util.Scanner;

/**
 * @author ZhuYi
 * @create 2025/4/7 14:33
 */
public class E最优分组 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int minK = Integer.MAX_VALUE;
        double p = sc.nextDouble();
        double miny = Double.MAX_VALUE;
        for (int k = n; k >= 1; k--) {
            if (n % k == 0) {
                double P = Math.pow(1 - p, k);
                double E = ((1 - P) * (k + 1) + P) * n / k;
                if (k == 1) E = n;
                if (E < miny) {
                    miny = E;
                    minK = k;
                }
            }
        }
        System.out.println(minK);

    }
}
